package com.cskaoyan.shopping.controller;

import com.cskaoyan.mall.commons.result.ResponseData;
import com.cskaoyan.mall.commons.result.ResponseUtil;
import com.cskaoyan.mall.constant.ShoppingRetCode;
import com.cskaoyan.shopping.dto.AllProductCateRequest;
import com.cskaoyan.shopping.dto.AllProductCateResponse;
import com.cskaoyan.shopping.dto.HomePageResponse;
import com.cskaoyan.shopping.service.IProductCateService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @Author Ajun de BBC
 * @Date 2022/8/1 15:56
 * @Version 1.5
 */

@Slf4j
@RestController
@RequestMapping("shopping")
public class ProductCateController {

    @Autowired
    IProductCateService iProductCateService;

    @RequestMapping("categories")
    public ResponseData getAllProductCate(AllProductCateRequest request){
        AllProductCateResponse response = iProductCateService.getAllProductCate(request);
        if(ShoppingRetCode.SUCCESS.getCode().equals(response.getCode())){
            return new ResponseUtil().setData(response.getProductCateDtoList(),response.getMsg());
        }
        return new ResponseUtil().setErrorMsg(response.getMsg());
    }
}
